package com.benben.springSecurity.config;

import com.benben.springSecurity.util.UserLonginIntercepor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
//public class InterceptorConfig  {

    @Autowired
    UserLonginIntercepor userLonginIntercepor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
          registry.addInterceptor(userLonginIntercepor).addPathPatterns("/*").excludePathPatterns("/index","/login");
    }

    @Bean
    public InternalResourceViewResolver viewResolver(){
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("/pages/");
        viewResolver.setSuffix(".html");
        return viewResolver;
    }
}